/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef CGeneralSetting_H
#define CGeneralSetting_H

#include <QObject>
#include <QProcess>
#include <QDebug>
#include <QDBusInterface>
#include <QDBusReply>
#include "core/appmanager.h"

// 需要派生自QObject
// 使用qmlRegisterType注册到QML中
class CGeneralSetting : public QObject
{
    Q_OBJECT

    //应用管理类实例化
    AppManager controlCenter;
public:
    // 属性：使用Q_PROPERTY注册属性，使之可以在QML中访问
    Q_PROPERTY(QString centerState READ getCenterState WRITE setCenterState NOTIFY centerStateChanged)

    explicit CGeneralSetting(QObject *parent = nullptr);

    // 给类属性添加访问方法--myName
    void setCenterState(const QString &centerState);

    //调用onboard的dbus中show方法
    void openOnboard();

    //调用应用管理的方法
    void openControlCenter(const QString &controlStr);

    //调用应用管理加参数的方法
    void openControlCenterConfig(const QString &controlStr, const QStringList &config);

    QString getCenterState() const;

    // 函数：通过Q_INVOKABLE宏标记的public函数可以在QML中访问
    Q_INVOKABLE void statePrint(); // 功能为打印信息

signals:
    // 信号：可以直接在QML中访问信号

    void centerStateChanged(const QString centerState);


public slots:
    // 槽函数：可以直接在QML中访问public槽函数

    void openGeneralSetting(const QString &str); // 一个带参数槽函数

private:
    // 类的属性
    QString myState;
    QProcess process;
};

#endif // CGeneralSetting_H







